package com.sports.controller;

import com.sports.pojo.Banner;
import com.sports.service.IBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/banner")
public class BannerController {
    @Autowired
    private IBannerService service;
    @GetMapping
    public List<Banner> list(){
        return service.list();
    }
    @GetMapping("/{id}")
    public Banner getInfo(@PathVariable Integer id) {
            return service.getById(id);
    }
    @PostMapping
    public Integer add(@RequestBody Banner banner){
        if (banner.getName()==null){
            return 0;
        }
        int rlt= service.add(banner);
        return rlt;
    }
    @PutMapping
    public Integer update(@RequestBody Banner banner){
        return service.update(banner);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return service.delete(id);
    }
}
